package com.lc.jpa.dao.impl;

import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceUnit;

import com.lc.jpa.Users;
import com.lc.jpa.dao.UsersManager;

@Remote
@Stateless
public class UsersManager2Bean implements UsersManager {

	@PersistenceUnit(unitName = "mysql")
	private EntityManagerFactory emf;

	@Override
	public void addUser(Users user) {

		System.out.println("由应用程序中自己管理EntityManager");

		EntityManager em = emf.createEntityManager();
		em.persist(user);
		em.flush();
		em.close();
	}

}
